import 'dart:developer';

///自定义消息解析
class CustomBean {
  final String? msg;
  final dynamic value;
  final String? inquiryId;
  final dynamic roomId;
  final String? graphId;
  final String? status;
  final List<String>? images;
  final dynamic type;
  final String? text;
  final String? link;
  final String? version;
  final String? caseId;
  final String? docId;
  final String? patientId;
  final String? age;
  final String? gender;
  final String? idCard;
  final String? intro;
  final String? phone;
  final String? userName;
  String? msgID;
  final String? orderId;
  final String? recipeId;

  CustomBean({this.msg,
    this.value,
    this.inquiryId,
    this.roomId,
    this.graphId,
    this.status,
    this.images,
    this.type,
    this.text,
    this.link,
    this.version,
    this.caseId,
    this.docId,
    this.patientId,
    this.age,
    this.gender,
    this.idCard,
    this.intro,
    this.phone,
    this.userName,
    this.msgID, this.orderId,this.recipeId});

  String getGender() {
    if (gender == '1') {
      return '男';
    } else if (gender == '2') {
      return '女';
    } else {
      return '未知';
    }
  }

  factory CustomBean.fromMap(Map<String, dynamic> map) {
    return new CustomBean(
        msg: map['msg'],
        value: map['value'],
        inquiryId: map['inquiryId'],
        roomId: map['roomId'],
        graphId: map['graphId'],
        status: map['status'],
        images: map['images'] == null
            ? List.empty()
            : (map['images'] as List).map((e) => e.toString()).toList(),
        type: map['type'],
        text: map['text'],
        link: map['link'],
        version: map['version'],
        caseId: map['caseId'],
        docId: map['docId'],
        patientId: map['patientId'],
        age: map['age'],
        gender: map['gender'],
        idCard: map['idCard'],
        intro: map['intro'],
        phone: map['phone'],
        userName: map['userName'],
        msgID: map['msgID'],
        recipeId: map['recipeId'],
        orderId: map['orderId']);
  }

  Map<String, dynamic> toMap() {
    return {
      'msg': msg,
      'value': value,
      'inquiryId': inquiryId,
      'roomId': roomId,
      'graphId': graphId,
      'status': status,
      'images': images,
      'type': type,
      'text': text,
      'link': link,
      'version': version,
      'caseId': caseId,
      'docId': docId,
      'patientId': patientId,
      'age': age,
      'gender': gender,
      'idCard': idCard,
      'intro': intro,
      'phone': phone,
      'userName': userName,
      'msgID': msgID,
      'orderId': orderId,
      'recipeId': recipeId
    };
  }
}
